In [3]:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
In [4]:
# We open the data 
df = pd.read_csv('Nikkei-2010-2012.csv',index_col="Ticker")
df
Out[4]:
2010-01-04 2010-01-05 2010-01-06 2010-01-07 2010-01-08 2010-01-12 2010-01-13 2010-01-14 2010-01-15 2010-01-18 ... 2012-12-14 2012-12-17 2012-12-18 2012-12-19 2012-12-20 2012-12-21 2012-12-25 2012-12-26 2012-12-27 2012-12-28
Ticker
4151.t 999.0 989.0 1003.0 984.0 991.0 984.0 985.0 990.0 989.0 975.0 ... 845.0 848.0 852.0 861.0 850.0 852.0 856.0 850.0 851.0 849.0
4502.t 3850.0 3870.0 3870.0 3930.0 3900.0 3940.0 3930.0 3970.0 3970.0 3945.0 ... 3805.0 3835.0 3845.0 3870.0 3875.0 3865.0 3865.0 3865.0 3860.0 3855.0
4503.t 694.0 700.0 700.0 700.0 702.0 700.0 696.0 704.0 702.0 697.0 ... 797.0 800.0 809.0 812.0 802.0 792.0 797.0 798.0 780.0 775.0
4506.t 979.0 984.0 991.0 982.0 981.0 977.0 979.0 982.0 980.0 965.0 ... 999.0 1013.0 1019.0 1026.0 1012.0 1010.0 1021.0 1032.0 1033.0 1035.0
4507.t 2003.0 2007.0 2007.0 1957.0 1930.0 1931.0 1904.0 1968.0 1957.0 1926.0 ... 1349.0 1382.0 1443.0 1462.0 1461.0 1457.0 1454.0 1469.0 1479.0 1437.0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
9501.t 2355.0 2375.0 2375.0 2424.0 2441.0 2445.0 2440.0 2484.0 2470.0 2465.0 ... 152.0 202.0 237.0 230.0 233.0 224.0 229.0 228.0 220.0 206.0
9502.t 2250.0 2259.0 2259.0 2273.0 2275.0 2286.0 2295.0 2308.0 2310.0 2317.0 ... 1084.0 1188.0 1147.0 1159.0 1157.0 1158.0 1177.0 1169.0 1162.0 1150.0
9503.t 2119.0 2123.0 2123.0 2121.0 2131.0 2137.0 2130.0 2139.0 2128.0 2125.0 ... 782.0 920.0 879.0 904.0 922.0 956.0 977.0 967.0 952.0 907.0
9531.t 1865.0 1880.0 1870.0 1885.0 1875.0 1875.0 1880.0 1870.0 1870.0 1870.0 ... 2015.0 2040.0 2030.0 2035.0 2045.0 2045.0 2030.0 2025.0 2010.0 1975.0
9532.t 1580.0 1615.0 1625.0 1630.0 1625.0 1630.0 1635.0 1635.0 1640.0 1630.0 ... 1615.0 1620.0 1595.0 1605.0 1610.0 1605.0 1595.0 1595.0 1580.0 1570.0

211 rows × 736 columns

In [40]:
# We use numpy to create the correlation matrix

#First convert the data into an array
mat = np.array(df.T[1::],float)
print(mat)
# Correlation:
C= np.corrcoef(mat.T)
C
[[ 999. 3850.  694. ... 2119. 1865. 1580.]
 [ 989. 3870.  700. ... 2123. 1880. 1615.]
 [1003. 3870.  700. ... 2123. 1870. 1625.]
 ...
 [ 850. 3865.  798. ...  967. 2025. 1595.]
 [ 851. 3860.  780. ...  952. 2010. 1580.]
 [ 849. 3855.  775. ...  907. 1975. 1570.]]
Out[40]:
array([[ 1.        ,  0.09219277,  0.2779862 , ...,  0.09768973,
         0.25497464,  0.41110819],
       [ 0.09219277,  1.        ,  0.03848122, ...,  0.68840317,
         0.25415725,  0.22398847],
       [ 0.2779862 ,  0.03848122,  1.        , ..., -0.56446518,
         0.68886603,  0.63470219],
       ...,
       [ 0.09768973,  0.68840317, -0.56446518, ...,  1.        ,
        -0.18973217, -0.17148206],
       [ 0.25497464,  0.25415725,  0.68886603, ..., -0.18973217,
         1.        ,  0.85186864],
       [ 0.41110819,  0.22398847,  0.63470219, ..., -0.17148206,
         0.85186864,  1.        ]])
In [41]:
# Now we plot the heat map of this matrix

plt.imshow(C)
plt.colorbar()
plt.show()
In [42]:
eig = np.linalg.eigvals(C)
eig_nonzero = [i for i in eig if abs(i) > 0.001]
a,b,c = plt.hist(eig_nonzero, density = True,range = [0,1], bins = 100)

Now we do it for the returns¶

For each entry, we define a new time series that has the returns instead of the prices. It is defined as $r_{i+1} = (p_{i+1} - p{i})/p_{i}$

In [55]:
### First we will compute the returns matrix
# We define the function "returns"

#This function takes as input a matrix where each rhow is a time series
def returns(mat):
    # T is the number of columns, that is, the number of times measured
    T = len(mat[0])
    
    #We define a new matrix, which will be the matrix of returns. It has one less column because
    # of the definition of returns
    new_mat = np.zeros((len(mat),T-1))
    
    #Iterate over every column
    for i in range(T-1):
        #We define the new column with the definition of the returns. 
        new_mat.T[i] = (mat.T[i+1]-mat.T[i])/mat.T[i]
    
    return(new_mat)

mat = np.array(df.T[1::].T,float)
print(mat)
print(np.around(returns(mat),5))
#It seems to be correct.
[[ 999.  989. 1003. ...  850.  851.  849.]
 [3850. 3870. 3870. ... 3865. 3860. 3855.]
 [ 694.  700.  700. ...  798.  780.  775.]
 ...
 [2119. 2123. 2123. ...  967.  952.  907.]
 [1865. 1880. 1870. ... 2025. 2010. 1975.]
 [1580. 1615. 1625. ... 1595. 1580. 1570.]]
[[-0.01001  0.01416 -0.01894 ... -0.00701  0.00118 -0.00235]
 [ 0.00519  0.       0.0155  ...  0.      -0.00129 -0.0013 ]
 [ 0.00865  0.       0.      ...  0.00125 -0.02256 -0.00641]
 ...
 [ 0.00189  0.      -0.00094 ... -0.01024 -0.01551 -0.04727]
 [ 0.00804 -0.00532  0.00802 ... -0.00246 -0.00741 -0.01741]
 [ 0.02215  0.00619  0.00308 ...  0.      -0.0094  -0.00633]]
In [62]:
# Compute the correlation matrix for the return matrix
mat_ret = returns(mat)
C= np.corrcoef(mat_ret)
C

plt.imshow(C,vmin=-1,vmax=1)
plt.colorbar()
plt.show()
In [63]:
#The eigenvalues of this matrix
eig = np.linalg.eigvals(C)
eig_nonzero = [i for i in eig if abs(i) > 0.001]
a,b,c = plt.hist(eig_nonzero, density = True,range = [0,1], bins = 100)

Epochs¶

Now we divide the time horizon into epochs of length 40 and generate the matrix and eigenvalues for each epoch. We do it first for the original matrix (not the returns)

In [65]:
epochs = []

# Number of epochs
N = df.shape[1]//40
N

for i in range(N):
    #Take the ith epoch
    ep = df.iloc[:,1 + i*40:1+(i+1)*40]
    epochs.append(ep)
In [66]:
# Plot the heatmap and eigenvalues of each epoch.

for i in range(N):
    ep = epochs[i]
    mat = np.array(ep)
    print(mat)
    
    print("epoch number: ", i)
    
    C= np.corrcoef(mat)
    
    print("Correlation matrix")
    plt.imshow(C)
    plt.colorbar()
    plt.show()
    
    
    print("Eigenvalues:")
    
    eig = np.linalg.eigvals(C)
    eig_nonzero = [i for i in eig if abs(i) > 0.001]
    a,b,c = plt.hist(eig_nonzero, density = True, bins = 100)
    plt.show()
[[ 999.  989. 1003. ...  921.  937.  961.]
 [3850. 3870. 3870. ... 4025. 4015. 4035.]
 [ 694.  700.  700. ...  669.  669.  655.]
 ...
 [2119. 2123. 2123. ... 2104. 2121. 2135.]
 [1865. 1880. 1870. ... 1935. 1965. 1985.]
 [1580. 1615. 1625. ... 1610. 1645. 1660.]]
epoch number:  0
Correlation matrix
Eigenvalues:
C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\histograms.py:851: ComplexWarning: Casting complex values to real discards the imaginary part
  indices = f_indices.astype(np.intp)
C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\histograms.py:904: ComplexWarning: Casting complex values to real discards the imaginary part
  db = np.array(np.diff(bin_edges), float)
C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\_asarray.py:102: ComplexWarning: Casting complex values to real discards the imaginary part
  return array(a, dtype, copy=False, order=order)
C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\transforms.py:1966: ComplexWarning: Casting complex values to real discards the imaginary part
  x, y = float(x), float(y)
[[ 957.  949.  968. ... 1032. 1022.  990.]
 [4035. 4025. 4020. ... 4000. 4000. 3920.]
 [ 650.  649.  657. ...  678.  662.  646.]
 ...
 [2138. 2131. 2133. ... 2110. 2105. 2069.]
 [1990. 2000. 1985. ... 1965. 1950. 1930.]
 [1645. 1630. 1645. ... 1670. 1650. 1620.]]
epoch number:  1
Correlation matrix
Eigenvalues:
[[ 994.  963.  933. ...  854.  857.  849.]
 [4050. 4000. 3905. ... 3865. 3870. 3875.]
 [ 661.  641.  632. ...  608.  611.  605.]
 ...
 [2091. 2084. 2067. ... 2168. 2165. 2163.]
 [1995. 2010. 1980. ... 2065. 2055. 2070.]
 [1635. 1645. 1620. ... 1610. 1615. 1620.]]
epoch number:  2
Correlation matrix
Eigenvalues:
[[ 846.          843.          842.         ...  829.
   816.          819.        ]
 [3820.         3845.         3890.         ... 3915.
  3825.         3875.        ]
 [ 598.          586.40002441  590.         ...  580.79998779
   577.59997559  582.20001221]
 ...
 [2161.         2139.         2141.         ... 2130.
  2137.         2138.        ]
 [2025.         2015.         2000.         ... 1955.
  1945.         1940.        ]
 [1600.         1590.         1600.         ... 1575.
  1565.         1570.        ]]
epoch number:  3
Correlation matrix
Eigenvalues:
[[ 856.          878.          822.         ...  815.
   822.          811.        ]
 [3850.         3900.         3860.         ... 3815.
  3815.         3775.        ]
 [ 581.20001221  588.20001221  580.59997559 ...  612.
   605.          602.        ]
 ...
 [2163.         2167.         2154.         ... 1937.
  1957.         1950.        ]
 [1955.         1970.         1960.         ... 1855.
  1865.         1845.        ]
 [1590.         1595.         1585.         ... 1465.
  1495.         1470.        ]]
epoch number:  4
Correlation matrix
Eigenvalues:
[[ 797.          788.          776.         ...  856.
   856.          857.        ]
 [3780.         3770.         3805.         ... 3995.
  3985.         3990.        ]
 [ 601.          598.79998779  599.59997559 ...  621.
   621.          624.        ]
 ...
 [1956.         2038.         2029.         ... 2021.
  2022.         2008.        ]
 [1865.         1895.         1900.         ... 1825.
  1825.         1820.        ]
 [1470.         1520.         1540.         ... 1580.
  1580.         1575.        ]]
epoch number:  5
Correlation matrix
Eigenvalues:
[[ 841.  847.  836. ...  839.  829.  828.]
 [3995. 4010. 3995. ... 4050. 4020. 4015.]
 [ 621.  622.  619. ...  651.  644.  642.]
 ...
 [2005. 2029. 2004. ... 2166. 2140. 2143.]
 [1810. 1820. 1800. ... 1845. 1845. 1845.]
 [1580. 1590. 1575. ... 1565. 1565. 1555.]]
epoch number:  6
Correlation matrix
Eigenvalues:
[[ 833.  838.  818. ...  800.  790.  784.]
 [4065. 4085. 4050. ... 3960. 3920. 3890.]
 [ 641.  647.  629. ...  625.  617.  614.]
 ...
 [2146. 2161. 2131. ... 1699. 1666. 1653.]
 [1825. 1840. 1810. ... 1805. 1790. 1750.]
 [1555. 1560. 1555. ... 1530. 1505. 1485.]]
epoch number:  7
Correlation matrix
Eigenvalues:
[[ 771.  792.  806. ...  779.  777.  779.]
 [3840. 3890. 3920. ... 3665. 3645. 3630.]
 [ 608.  616.  618. ...  619.  619.  614.]
 ...
 [1626. 1643. 1702. ... 1498. 1456. 1495.]
 [1755. 1770. 1795. ... 1855. 1870. 1850.]
 [1475. 1485. 1490. ... 1535. 1515. 1515.]]
epoch number:  8
Correlation matrix
Eigenvalues:
[[ 771.          766.          774.         ...  770.
   763.          761.        ]
 [3630.         3645.         3675.         ... 3630.
  3620.         3615.        ]
 [ 608.          611.          618.         ...  576.
   579.59997559  575.20001221]
 ...
 [1465.         1471.         1529.         ... 1316.
  1332.         1371.        ]
 [1845.         1825.         1825.         ... 1740.
  1770.         1785.        ]
 [1510.         1510.         1515.         ... 1515.
  1560.         1565.        ]]
epoch number:  9
Correlation matrix
Eigenvalues:
[[ 764.          755.          760.         ...  894.
   908.          898.        ]
 [3650.         3625.         3610.         ... 3595.
  3605.         3590.        ]
 [ 573.          576.59997559  573.         ...  571.
   587.          579.20001221]
 ...
 [1409.         1396.         1341.         ... 1160.
  1166.         1216.        ]
 [1790.         1785.         1755.         ... 1750.
  1730.         1735.        ]
 [1580.         1575.         1540.         ... 1545.
  1540.         1555.        ]]
epoch number:  10
Correlation matrix
Eigenvalues:
[[ 900.          885.          870.         ...  922.
   921.          918.        ]
 [3575.         3565.         3520.         ... 3215.
  3250.         3225.        ]
 [ 577.59997559  576.79998779  565.         ...  608.
   614.          605.        ]
 ...
 [1215.         1210.         1194.         ... 1116.
  1156.         1148.        ]
 [1735.         1720.         1705.         ... 1740.
  1780.         1755.        ]
 [1545.         1545.         1505.         ... 1510.
  1540.         1520.        ]]
epoch number:  11
Correlation matrix
Eigenvalues:
[[ 920.  942.  942. ...  914.  901.  903.]
 [3215. 3265. 3295. ... 3435. 3425. 3475.]
 [ 605.  619.  617. ...  647.  639.  646.]
 ...
 [1122. 1141. 1154. ... 1396. 1425. 1406.]
 [1750. 1760. 1770. ... 1840. 1820. 1830.]
 [1505. 1525. 1525. ... 1570. 1565. 1565.]]
epoch number:  12
Correlation matrix
Eigenvalues:
[[ 909.  908.  899. ...  856.  859.  856.]
 [3505. 3515. 3560. ... 3435. 3460. 3480.]
 [ 650.  652.  653. ...  648.  661.  658.]
 ...
 [1433. 1393. 1398. ... 1292. 1293. 1299.]
 [1830. 1845. 1825. ... 1905. 1935. 1935.]
 [1560. 1580. 1570. ... 1605. 1625. 1630.]]
epoch number:  13
Correlation matrix
Eigenvalues:
[[ 859.  865.  853. ...  771.  778.  779.]
 [3460. 3510. 3450. ... 3300. 3335. 3340.]
 [ 651.  659.  649. ...  622.  623.  628.]
 ...
 [1304. 1282. 1284. ... 1045. 1045. 1027.]
 [1960. 1945. 1950. ... 1850. 1865. 1860.]
 [1645. 1630. 1630. ... 1525. 1545. 1535.]]
epoch number:  14
Correlation matrix
Eigenvalues:
[[ 787.          787.          782.         ...  890.00231934
   892.22998047  887.        ]
 [3340.         3355.         3370.         ... 3675.
  3685.         3662.        ]
 [ 635.          633.          633.         ...  772.
   772.20001221  767.        ]
 ...
 [1042.         1018.          984.         ...  667.
   675.          664.        ]
 [1860.         1855.         1860.         ... 2065.
  2075.         2040.        ]
 [1540.         1535.         1545.         ... 1695.
  1680.55004883 1670.        ]]
epoch number:  15
Correlation matrix
Eigenvalues:
[[ 893.          911.37042236  918.         ...  921.
   932.          943.        ]
 [3658.55151367 3643.70288086 3665.         ... 3545.
  3550.         3580.        ]
 [ 771.          781.40002441  783.79998779 ...  784.
   773.          777.        ]
 ...
 [ 668.34228516  677.          683.64538574 ...  619.
   616.          571.        ]
 [2063.04711914 2100.         2105.         ... 2140.
  2145.         2110.        ]
 [1671.71801758 1690.         1690.         ... 1725.
  1700.         1665.        ]]
epoch number:  16
Correlation matrix
Eigenvalues:
[[ 915.  916.  925. ...  839.  856.  855.]
 [3525. 3530. 3535. ... 3755. 3770. 3795.]
 [ 759.  759.  769. ...  831.  832.  828.]
 ...
 [ 562.  591.  597. ...  733.  733.  734.]
 [2115. 2140. 2115. ... 2030. 2035. 2020.]
 [1655. 1680. 1680. ... 1605. 1615. 1615.]]
epoch number:  17
Correlation matrix
Eigenvalues:

Now we do the same but for the matrix of returns¶

In [77]:
#Create the matrix of returns
mat = np.array(df.T[1::].T,float)
mat_ret = returns(mat)

#Number of epochs:
Ne = len(mat_ret[0])//40

epochs = []
for i in range(Ne):
    #Take the ith epoch
    ep = mat_ret[:,i*40:i*40+40]
    epochs.append(ep)
In [79]:
# Plot the heatmap and eigenvalues of each epoch.

for i in range(N):
    ep = epochs[i]
    print(ep)
    
    print("epoch number: ", i)
    
    C= np.corrcoef(ep)
    
    print("Correlation matrix")
    plt.imshow(C,vmin=-1,vmax=1)
    plt.colorbar()
    plt.show()
    
    
    print("Eigenvalues:")
    
    eig = np.linalg.eigvals(C)
    eig_nonzero = [i for i in eig if abs(i) > 0.001]
    a,b,c = plt.hist(eig_nonzero, density = True, bins = 100)
    plt.show()
[[-0.01001001  0.01415571 -0.01894317 ...  0.01737242  0.02561366
  -0.00416233]
 [ 0.00519481  0.          0.01550388 ... -0.00248447  0.00498132
   0.        ]
 [ 0.00864553  0.          0.         ...  0.         -0.02092676
  -0.00763359]
 ...
 [ 0.00188768  0.         -0.00094206 ...  0.00807985  0.00660066
   0.00140515]
 [ 0.0080429  -0.00531915  0.00802139 ...  0.01550388  0.01017812
   0.00251889]
 [ 0.0221519   0.00619195  0.00307692 ...  0.02173913  0.00911854
  -0.00903614]]
epoch number:  0
Correlation matrix
Eigenvalues:
[[-0.00835946  0.02002107  0.0072314  ... -0.00968992 -0.03131115
   0.0040404 ]
 [-0.00247831 -0.00124224  0.00621891 ...  0.         -0.02
   0.03316327]
 [-0.00153846  0.01232666  0.01369863 ... -0.02359882 -0.02416918
   0.02321981]
 ...
 [-0.00327409  0.00093853 -0.00468823 ... -0.00236967 -0.01710214
   0.01063316]
 [ 0.00502513 -0.0075      0.00251889 ... -0.00763359 -0.01025641
   0.03367876]
 [-0.00911854  0.00920245  0.00303951 ... -0.01197605 -0.01818182
   0.00925926]]
epoch number:  1
Correlation matrix
Eigenvalues:
[[-0.03118712 -0.03115265  0.02250804 ...  0.00351288 -0.00933489
  -0.00353357]
 [-0.01234568 -0.02375     0.00128041 ...  0.00129366  0.00129199
  -0.01419355]
 [-0.03025719 -0.01404056  0.00474684 ...  0.00493421 -0.00981997
  -0.01157025]
 ...
 [-0.00334768 -0.00815739  0.01112724 ... -0.00138376 -0.00092379
  -0.00092464]
 [ 0.0075188  -0.01492537 -0.00252525 ... -0.00484262  0.00729927
  -0.02173913]
 [ 0.00611621 -0.01519757  0.00308642 ...  0.00310559  0.00309598
  -0.01234568]]
epoch number:  2
Correlation matrix
Eigenvalues:
[[-0.0035461  -0.00118624  0.01068884 ... -0.01568154  0.00367647
   0.04517705]
 [ 0.0065445   0.01170351  0.         ... -0.02298851  0.0130719
  -0.00645161]
 [-0.01939795  0.00613911  0.         ... -0.00550966  0.00796405
  -0.00171762]
 ...
 [-0.01018047  0.00093502 -0.0032695  ...  0.00328638  0.00046795
   0.01169317]
 [-0.00493827 -0.00744417  0.         ... -0.00511509 -0.00257069
   0.00773196]
 [-0.00625     0.00628931  0.         ... -0.00634921  0.00319489
   0.01273885]]
epoch number:  3
Correlation matrix
Eigenvalues:
[[ 0.02570093 -0.06378132 -0.02189781 ...  0.00858896 -0.013382
  -0.01726264]
 [ 0.01298701 -0.01025641 -0.00129534 ...  0.         -0.01048493
   0.0013245 ]
 [ 0.01204405 -0.01292084  0.0196349  ... -0.01143791 -0.00495868
  -0.00166113]
 ...
 [ 0.00184928 -0.00599908  0.01021356 ...  0.01032525 -0.0035769
   0.00307692]
 [ 0.00767263 -0.00507614  0.01020408 ...  0.00539084 -0.01072386
   0.01084011]
 [ 0.00314465 -0.00626959  0.00630915 ...  0.02047782 -0.01672241
   0.        ]]
epoch number:  4
Correlation matrix
Eigenvalues:
[[-0.01129235 -0.01522843  0.00257732 ...  0.          0.00116822
  -0.01866978]
 [-0.0026455   0.00928382  0.00919842 ... -0.00250313  0.00125471
   0.00125313]
 [-0.00366059  0.00133598 -0.00066705 ...  0.          0.00483092
  -0.00480769]
 ...
 [ 0.04192229 -0.00441609 -0.00788566 ...  0.0004948  -0.00692384
  -0.00149402]
 [ 0.01608579  0.00263852 -0.01052632 ...  0.         -0.00273973
  -0.00549451]
 [ 0.03401361  0.01315789  0.00324675 ...  0.         -0.00316456
   0.0031746 ]]
epoch number:  5
Correlation matrix
Eigenvalues:
[[ 0.00713436 -0.01298701  0.01196172 ... -0.01191895 -0.00120627
   0.00603865]
 [ 0.00375469 -0.00374065  0.00125156 ... -0.00740741 -0.00124378
   0.0124533 ]
 [ 0.00161031 -0.00482315  0.00323102 ... -0.01075269 -0.00310559
  -0.00155763]
 ...
 [ 0.01197007 -0.01232134  0.00449102 ... -0.01200369  0.00140187
   0.00139991]
 [ 0.00552486 -0.01098901  0.         ...  0.          0.
  -0.01084011]
 [ 0.00632911 -0.00943396  0.00952381 ...  0.         -0.00638978
   0.        ]]
epoch number:  6
Correlation matrix
Eigenvalues:
[[ 0.0060024  -0.02386635  0.01833741 ... -0.0125     -0.00759494
  -0.01658163]
 [ 0.00492005 -0.00856793  0.0037037  ... -0.01010101 -0.00765306
  -0.01285347]
 [ 0.00936037 -0.02782071  0.01430843 ... -0.0128     -0.00486224
  -0.00977199]
 ...
 [ 0.00698975 -0.01388246  0.00046926 ... -0.01942319 -0.00780312
  -0.01633394]
 [ 0.00821918 -0.01630435  0.         ... -0.00831025 -0.02234637
   0.00285714]
 [ 0.00321543 -0.00320513  0.00321543 ... -0.01633987 -0.01328904
  -0.00673401]]
epoch number:  7
Correlation matrix
Eigenvalues:
[[ 0.02723735  0.01767677  0.02233251 ... -0.00256739  0.002574
  -0.01026958]
 [ 0.01302083  0.00771208  0.00510204 ... -0.00545703 -0.00411523
   0.        ]
 [ 0.01315789  0.00324675  0.01294498 ...  0.         -0.00807754
  -0.00977199]
 ...
 [ 0.0104551   0.03590992  0.00293772 ... -0.02803738  0.02678571
  -0.02006689]
 [ 0.00854701  0.01412429  0.         ...  0.00808625 -0.01069519
  -0.0027027 ]
 [ 0.00677966  0.003367    0.02348993 ... -0.01302932  0.
  -0.00330033]]
epoch number:  8
Correlation matrix
Eigenvalues:
[[-0.00648508  0.01044386 -0.01162791 ... -0.00909091 -0.00262123
   0.00394218]
 [ 0.00413223  0.00823045  0.01088435 ... -0.00275482 -0.00138122
   0.00968188]
 [ 0.00493421  0.01145663  0.00809061 ...  0.00624996 -0.00759138
  -0.00382478]
 ...
 [ 0.00409556  0.03942896  0.04643558 ...  0.01215805  0.02927928
   0.02771699]
 [-0.01084011  0.         -0.00547945 ...  0.01724138  0.00847458
   0.00280112]
 [ 0.          0.00331126  0.00660066 ...  0.02970297  0.00320513
   0.00958466]]
epoch number:  9
Correlation matrix
Eigenvalues:
[[-0.0117801   0.00662252  0.03289474 ...  0.01565996 -0.01101322
   0.00222717]
 [-0.00684932 -0.00413793  0.00138504 ...  0.00278164 -0.00416089
  -0.00417827]
 [ 0.00628268 -0.00624345 -0.00628268 ...  0.02802102 -0.01328788
  -0.00276249]
 ...
 [-0.0092264  -0.03939828  0.01193139 ...  0.00517241  0.04288165
  -0.00082237]
 [-0.0027933  -0.01680672 -0.00854701 ... -0.01142857  0.00289017
   0.        ]
 [-0.00316456 -0.02222222 -0.00324675 ... -0.00323625  0.00974026
  -0.00643087]]
epoch number:  10
Correlation matrix
Eigenvalues:
[[-0.01666667 -0.01694915 -0.01034483 ... -0.0010846  -0.00325733
   0.00217865]
 [-0.0027972  -0.01262272 -0.00284091 ...  0.01088647 -0.00769231
  -0.00310078]
 [-0.00138502 -0.02045768 -0.00212392 ...  0.00986842 -0.01465798
   0.        ]
 ...
 [-0.00411523 -0.01322314 -0.00167504 ...  0.03584229 -0.00692042
  -0.02264808]
 [-0.00864553 -0.00872093 -0.0058651  ...  0.02298851 -0.01404494
  -0.002849  ]
 [ 0.         -0.02588997 -0.00664452 ...  0.01986755 -0.01298701
  -0.00986842]]
epoch number:  11
Correlation matrix
Eigenvalues:
[[ 0.02391304  0.          0.00955414 ... -0.01422319  0.00221976
   0.00664452]
 [ 0.0155521   0.00918836  0.0091047  ... -0.00291121  0.01459854
   0.00863309]
 [ 0.0231405  -0.00323102  0.00486224 ... -0.01236476  0.01095462
   0.00619195]
 ...
 [ 0.01693405  0.01139351 -0.02512998 ...  0.02077364 -0.01333333
   0.01920341]
 [ 0.00571429  0.00568182 -0.01694915 ... -0.01086957  0.00549451
   0.        ]
 [ 0.01328904  0.         -0.00983607 ... -0.00318471  0.
  -0.00319489]]
epoch number:  12
Correlation matrix
Eigenvalues:
[[-0.00110011 -0.00991189 -0.0189099  ...  0.00350467 -0.00349243
   0.00350467]
 [ 0.00285307  0.01280228  0.01123596 ...  0.00727802  0.00578035
  -0.00574713]
 [ 0.00307692  0.00153374  0.00153139 ...  0.02006173 -0.00453858
  -0.0106383 ]
 ...
 [-0.02791347  0.00358938 -0.00786838 ...  0.00077399  0.00464037
   0.00384911]
 [ 0.00819672 -0.01084011  0.00273973 ...  0.01574803  0.
   0.0129199 ]
 [ 0.01282051 -0.00632911 -0.01273885 ...  0.01246106  0.00307692
   0.00920245]]
epoch number:  13
Correlation matrix
Eigenvalues:
[[ 0.00698487 -0.01387283 -0.00820633 ...  0.00907912  0.00128535
   0.01026958]
 [ 0.01445087 -0.01709402 -0.00434783 ...  0.01060606  0.00149925
   0.        ]
 [ 0.01228879 -0.01517451 -0.00154083 ...  0.00160772  0.00802568
   0.0111465 ]
 ...
 [-0.01687117  0.00156006 -0.0194704  ...  0.         -0.01722488
   0.01460565]
 [-0.00765306  0.00257069  0.0025641  ...  0.00810811 -0.00268097
   0.        ]
 [-0.00911854  0.         -0.00613497 ...  0.01311475 -0.00647249
   0.00325733]]
epoch number:  14
Correlation matrix
Eigenvalues:
[[ 0.         -0.00635324  0.01023018 ...  0.00250298 -0.0058617
   0.00676437]
 [ 0.00449102  0.00447094  0.01632047 ...  0.00272109 -0.00624152
  -0.00094169]
 [-0.00314961  0.          0.01895735 ...  0.00025908 -0.00673402
   0.00521512]
 ...
 [-0.02303263 -0.03339882  0.00406504 ...  0.011994   -0.0162963
   0.00653959]
 [-0.00268817  0.00269542  0.02956989 ...  0.00484262 -0.01686747
   0.01129761]
 [-0.00324675  0.00651466  0.01941748 ... -0.00852504 -0.00627774
   0.00102875]]
epoch number:  15
Correlation matrix
Eigenvalues:
[[ 0.02057158  0.0072743  -0.00108932 ...  0.01194354  0.01180258
  -0.02969247]
 [-0.00405861  0.00584491  0.         ...  0.00141044  0.0084507
  -0.01536313]
 [ 0.01348901  0.00307136 -0.01122734 ... -0.01403061  0.00517464
  -0.02316602]
 ...
 [ 0.01295401  0.00981593 -0.02142249 ... -0.00484653 -0.07305195
  -0.01576182]
 [ 0.0179118   0.00238095 -0.0023753  ...  0.00233645 -0.01631702
   0.00236967]
 [ 0.01093604  0.          0.00295858 ... -0.01449275 -0.02058824
  -0.00600601]]
epoch number:  16
Correlation matrix
Eigenvalues:
[[ 0.0010929   0.00982533 -0.01297297 ...  0.02026222 -0.00116822
  -0.00116959]
 [ 0.00141844  0.00141643  0.00707214 ...  0.00399467  0.0066313
   0.00263505]
 [ 0.          0.01317523 -0.01690507 ...  0.00120337 -0.00480769
   0.        ]
 ...
 [ 0.05160142  0.01015228  0.03852596 ...  0.          0.00136426
   0.03405995]
 [ 0.01182033 -0.01168224  0.00472813 ...  0.00246305 -0.00737101
   0.0049505 ]
 [ 0.01510574  0.         -0.00595238 ...  0.00623053  0.
  -0.00619195]]
epoch number:  17
Correlation matrix
Eigenvalues:
In [71]:
len(mat_ret)
Out[71]:
211
In [ ]: